package com.thewaybetter.modules.server.model;

import java.io.Serializable;
import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.thewaybetter.modules.client.model.SlimIdea;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Idea implements Serializable{

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;
	
	@Persistent
	private String title;
	
	@Persistent
	private String content;
	
	@Persistent
	private Date updatedAt;
	
	public Idea(){
		updatedAt = new Date();
	}
	
	public Idea(SlimIdea i){
		this();
		this.id = i.getId();
		this.title = i.getTitle();
		this.content = i.getContent();
	}
	
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	
	public SlimIdea convert(){
		SlimIdea s = new SlimIdea();
		s.setId(this.id);
		s.setTitle(this.title);
		s.setContent(this.content);
		s.setUpdatedAt(this.updatedAt);
		return s;
	}

	public void setUpdatedAt(Date updatedAt) {
		this.updatedAt = updatedAt;
	}

	public Date getUpdatedAt() {
		return updatedAt;
	}
	
}
